{extend name="layout/layout" /}
{block name="pagecss"}
<style>
	.zhushi a,.zhushi button{
		margin-left: 15px;
	}
</style>
{/block}
{block name="content"}
<div class="row">
	<div class="col-lg-12">
		<div class="box box-success">
			<div class="box-header with-border">
				<h3 class="box-title">顾客可以在线使用微信支付，或到店当面支付</h3>
				<div class="box-tools pull-right">

				</div>
			</div>
			<div class="box-body">
				<div class="box-content col-md-9  table-bordered table" style="padding: 20px">

					<div style="float: left;">
						<img class="margin-right" src="__STATIC__/admin/img/u5340.png">
					</div>
					<div style="margin-left: 100px;">
						<div style="float: right">
							{if condition="($face_payment.isFacePayment == 1)"}
							<button class="btn btn-olive change_btn  bg-olive" data-url="{:url('admin/paymethod/setFacePayment')}" data-value="2">
								已开启
							</button>
							{else /}
							<button class="btn bg-navy change_btn" data-url="{:url('admin/paymethod/setFacePayment')}" data-value="1">
								未开启
							</button>
							{/if}
						</div>
						<div style="margin-right: 100px">
							<p style="font-size: 18px">当面付</p>
							<p>顾客可以到店时进行当面付款</p>
						</div>
					</div>

					<!--<span class="form-control-static  margin-right">-->
						<!--<img class="margin-right" src="__STATIC__/admin/img/u5340.png">-->
					<!--</span>-->
					<!--<span class="form-control-static zhushi margin-right">-->
						<!--<span style="font-size: 18px">当面付</span>-->
						<!--</br>-->
						<!--顾客可以到店时进行当面付款-->
						<!--{if condition="($face_payment.isFacePayment == 1)"}-->
							<!--<button class="btn btn-info change_btn" data-url="{:url('admin/paymethod/setFacePayment')}" data-value="2">-->
								<!--已开启-->
							<!--</button>-->
						<!--{else /}-->
							<!--<button class="btn bg-navy change_btn" data-url="{:url('admin/paymethod/setFacePayment')}" data-value="1">-->
								<!--未开启-->
							<!--</button>-->
						<!--{/if}-->
					<!--</span>-->
				</div>

				<div class="box-content col-md-9  table-bordered table" style="padding: 20px">

					<div style="float: left;">
						<img class="margin-right" src="__STATIC__/admin/img/u5341.png">
					</div>
					<div style="margin-left: 100px;">
						<div style="float: right">
							<a class="btn btn-info" href="{:url('/MiniProgram')}">设置</a>
						</div>
						<div style="margin-right: 100px">
							<p style="font-size: 18px">微信支付</p>
							<p>顾客可以通过微信支付付款</p>
						</div>
					</div>

					<!--<span class="form-control-static  margin-right">-->
						<!--<img class="margin-right" src="__STATIC__/admin/img/u5341.png">-->
					<!--</span>-->
					<!--<span class="form-control-static zhushi margin-right">-->
						<!--<span style="font-size: 18px">微信支付</span>-->
						<!--</br>-->
						<!--顾客可以通过微信支付付款-->
						<!--<a class="btn btn-info" href="{:url('/MiniProgram')}">设置</a>-->
					<!--</span>-->
				</div>
			</div>
		</div>
	</div>
</div>
{/block}

{block name="pagescript"}
<script>
	var value = "{$face_payment.isFacePayment}";

	$(document).on('click', '.change_btn', function () {
	    var _this = $(this);
	    var url = $(this).data('url');
	    //var isFacePayment = _this.data('value');
		if(value == 1){
		    var isFacePayment = 2;
		}else{
		    var isFacePayment = 1;
		}
        layer.load(2, {shade: [0.8,'#000000']}); // 打开loading
        $.ajax({
            type: "POST",
            url: url,
            data: {'isFacePayment': isFacePayment},
            dataType:'json',
            cache: false,
            success: function(data){
                layer.closeAll('loading'); // 关闭loading
                if(data.status == 1){
                    if(value == 1){
                        value = 2;
                        _this.attr('data-value', value);
                        _this.removeClass('btn-olive');
                        _this.removeClass('bg-olive');
                        _this.addClass('bg-navy');
                        _this.empty().html('未开启');
					}else{
                        value = 1;
                        _this.attr('data-value', value);
                        _this.removeClass('bg-navy');
                        _this.addClass('btn-olive');
                        _this.addClass('bg-olive');
                        _this.empty().html('已开启');
					}
				}else{
                    layer.msg(data.msg);
				}
            }
        });
        return false;
    });
</script>
{/block}
